import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.Stack;

public class bai3 {
	static int test_cae, N, Answer;
	static String mo = "<({[";
	static String dong = ">)}]";
	static String s;
	static Stack<Character> stack;

	public static void main(String[] args) throws FileNotFoundException {
		Scanner sc = new Scanner(System.in);
		// sc = new Scanner(new FileInputStream("input.txt"));
		for (int test_case = 1; test_case <= 1; test_case++) {
			stack = new Stack<Character>();
			// N = sc.nextInt();
			s = sc.nextLine();
			if (checkBracket())
				Answer = 1;
			else
				Answer = 0;

			System.out.println("#" + "test_case" + " " + Answer);

		}
	}

	private static boolean checkBracket() {
		for (int i = 0; i < s.length(); i++) {
			if (mo.indexOf(s.charAt(i)) != -1) {
				stack.push(s.charAt(i));
			} else {
				if(stack.isEmpty())
					return false;
				Character temp = stack.pop();
				if (dong.indexOf(s.charAt(i)) != mo.indexOf(temp))
					return false;
			}
		}
		if (stack.empty()) {
			return true;
	}
		return false;
	}
}
